﻿using ERPSystem.Common.DTO;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using SalesManagementWrite.API.OutOfStock;

namespace SalesManagementWrite.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OutOfStockController : ControllerBase
    {
        private readonly IMediator _mediator;

        public OutOfStockController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 销售订单出库新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> SaleOutOfWarehouseCreate(SaleOutOfWarehouseCreateCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request, cancellationToken);
        }

        /// <summary>
        /// 处理销售出库物料新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result>  SaleMaterialCreate(SellOutMaterialsCreateCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request, cancellationToken);
        }

        /// <summary>
        /// 导入销售出库
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> Handle(SaleOutOfStockDCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request, cancellationToken);
        }


    }
}
